<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>

        Function.prototype.myCall = function(msg,...ags){
            //声明变量接收传入的第一个参数再转换为对象
            const teat = Object(msg) || window
            //声明一个对象方法接收一份调用函数的this
            teat.fn = this
            //执行一遍对象方法，this此时指向调用对象，接收结果
            var res = teat.fn(...ags)
            //删除掉自定义的对象方法
            delete teat.fn
            //返回执行结果
            return res
        }


        Function.prototype.msCall = function(thisobj,...agrs){
            thisobj.temp = this
            const res = thisobj.temp(...agrs)
            delete thisobj.temp
            return res
        }


        const obj = {name:'1'}

        function steat(...ags){
            console.log('fn的this指向',this,...ags);
        }

        // steat.myCall(obj,3,4)
        steat.myCall(undefined,3,4)
    </script>

</body>
</html>